package com.pdg.mcplugin.ranger;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import com.pdg.mcplugin.common.ArgumentList;
import com.pdg.mcplugin.common.baseclasses.PluginBase;
import com.pdg.mcplugin.ranger.commandprocessors.CommandProcessor;
import com.pdg.mcplugin.ranger.conversations.RangerConversationFactory;
import com.pdg.mcplugin.ranger.dataproviders.DataProvider;

public class Ranger extends PluginBase{
	private static final String COMMAND_RANGER = "RANGER";
	private DataProvider dataProvider=null;
	public DataProvider getDataProvider(){
		if(dataProvider==null){
			dataProvider = new DataProvider(this);
		}
		return dataProvider;
	}
	private CommandProcessor commandProcessor=null;
	private CommandProcessor getCommandProcessor() {
		if(commandProcessor==null){
			commandProcessor = new CommandProcessor(this);
		}
		return commandProcessor;
	}
	private PermissionChecker permissionChecker = null;
	public PermissionChecker getPermissionChecker(){
		if(permissionChecker==null){
			permissionChecker = new PermissionChecker(this);
		}
		return permissionChecker;
	}
	private RangerConversationFactory rangerConversationFactory = null;
	public RangerConversationFactory getConversationFactory(){
		if(rangerConversationFactory==null){
			rangerConversationFactory = new RangerConversationFactory(this);
		}
		return rangerConversationFactory;
	}

	@Override
	protected void disablePlugin() {
	}

	@Override
	protected boolean enablePlugin() {
		this.saveDefaultConfig();
		return true;
	}
	//handle commands
	public boolean onCommand(CommandSender theCommandSender, Command theCommand, String theLabel, String[] theArgs){
		ArgumentList theArgumentList = new ArgumentList(theArgs);
		if(theCommand.getName().equalsIgnoreCase(COMMAND_RANGER)){
			return getCommandProcessor().processCommand(theCommandSender,theArgumentList);
		}
		return false;
	}

}
